package com.cuit.service;

import com.cuit.mapper.CommentMapper;
import com.cuit.pojo.Comment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CommentService {
    @Autowired
    CommentMapper commentMapper;

    public List<Comment> findCommentByArticleId(int articleId) {

        return commentMapper.findCommentByArticleId(articleId);
    }

    public void insertComment(String commentText, int userId, int articleId) {
        Comment comment = new Comment();
        comment.setText(commentText);
        comment.setUserId(userId);
        comment.setArticleId(articleId);
        commentMapper.insertComment(comment);
    }
}
